import java.util.LinkedList;

import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

public class MyTable implements TableModel {
		private String[][] data;
		private String[] header;
		private LinkedList<TableModelListener> listen;

		public MyTable(String[][] data, String[] header)
		{
			this.data = data;
			this.header = header;
			listen = new LinkedList<TableModelListener>();
		}

		public void setTable(String[][] d)
		{
			data = d;
			for (TableModelListener t : listen)
			{
				t.tableChanged(new TableModelEvent(this));
			}

		}

		public String[][] getData()
		{
			return data;
		}

		@Override
		public void addTableModelListener(TableModelListener l)
		{
			listen.add(l);
		}

		@Override
		public Class<?> getColumnClass(int columnIndex)
		{
			return String.class;
		}

		@Override
		public int getColumnCount()
		{
			return header.length;
		}

		@Override
		public String getColumnName(int columnIndex)
		{
			return header[columnIndex];
		}

		@Override
		public int getRowCount()
		{
			return data.length;
		}

		@Override
		public Object getValueAt(int rowIndex, int columnIndex)
		{
			return data[rowIndex][columnIndex];
		}

		@Override
		public boolean isCellEditable(int rowIndex, int columnIndex)
		{
			return true;
		}

		@Override
		public void removeTableModelListener(TableModelListener l)
		{
			listen.remove(l);
		}

		@Override
		public void setValueAt(Object aValue, int rowIndex, int columnIndex)
		{
			data[rowIndex][columnIndex] = (String) aValue;
		}

	}